import { EnumMessage, EvalWorkloadMethod, Priority, enumUtils } from '@xcan-angus/infra';
import { BugLevel, TaskStatus, TaskType, AssociateUserType } from '@/enums/enums';
import { AttachmentInfo, ProgressInfo, TagInfo } from '@/types/types';

import { CaseInfo } from '@/views/test/types';

/** Task type name mapping for UI display */
export const getTaskTypeName = () => {
  return enumUtils.enumToMap(TaskType);
};

/**
 * Task information interface containing all task-related data
 */
export type TaskInfo = {
  id: string;
  name: string;
  code: string;
  projectId: string;
  projectName: string;
  sprintId: string;
  sprintName: string;
  sprintAuth: boolean;
  moduleId: string;
  moduleName: string;
  backlog: boolean;
  priority: EnumMessage<Priority>;
  status: EnumMessage<TaskStatus>;
  progress: ProgressInfo;
  taskType: EnumMessage<TaskType>;
  bugLevel: EnumMessage<BugLevel>;
  softwareVersion: string;
  startDate: string;
  deadlineDate: string;
  confirmedDate: string;
  canceledDate: string;
  completedDate: string;
  processedDate: string;
  assigneeId: string;
  assigneeName: string;
  assigneeAvatar: string;
  confirmerId: string;
  confirmerName: string;
  testerId: string;
  testerName: string;
  escapedBug: boolean;
  unplanned: boolean;
  parentTaskId: string;
  parentTaskName: string;
  evalWorkloadMethod: EnumMessage<EvalWorkloadMethod>;
  evalWorkload: string;
  actualWorkload: string;
  failNum: number;
  totalNum: number;
  attachments?: AttachmentInfo[] | undefined;
  description: string;
  currentAssociateType: EnumMessage<AssociateUserType>[];
  confirmTask: boolean;
  overdue: boolean;
  favourite: boolean;
  follow: boolean;
  tags: TagInfo[];
  tenantId: string;
  createdBy: string;
  createdByName: string;
  createdDate: string;
  avatar: string;
  lastModifiedBy: string;
  lastModifiedByName: string;
  lastModifiedDate: string;
}

export type TaskDetail = {
  id: string;
  name: string;
  code: string;
  projectId: string;
  projectName: string;
  sprintId: string;
  sprintName: string;
  sprintAuth: boolean;
  moduleId: string;
  moduleName: string;
  backlog: boolean;
  priority: EnumMessage<Priority>;
  status: EnumMessage<TaskStatus>;
  progress: ProgressInfo | number;
  subTaskProgress: ProgressInfo;
  taskType: EnumMessage<TaskType>;
  bugLevel: EnumMessage<BugLevel>;
  softwareVersion: string;
  startDate: string;
  deadlineDate: string;
  confirmedDate: string;
  canceledDate: string;
  completedDate: string;
  processedDate: string;
  assigneeId: string;
  assigneeName: string;
  assigneeAvatar: string;
  confirmerId: string;
  confirmerName: string;
  testerId: string;
  testerName: string;
  escapedBug: boolean;
  unplanned: boolean;
  parentTaskId: string;
  parentTaskName: string;
  evalWorkloadMethod: EnumMessage<EvalWorkloadMethod>;
  evalWorkload: string;
  actualWorkload: string;
  failNum: number;
  totalNum: number;
  attachments?: AttachmentInfo[] | undefined;
  description: string;
  currentAssociateType: EnumMessage<AssociateUserType>[];
  confirmTask: boolean;
  overdue: boolean;
  favourite: boolean;
  follow: boolean;
  tags: TagInfo[];
  refTaskInfos: TaskInfo[];
  refCaseInfos: CaseInfo[];
  subTaskInfos: TaskInfo[];
  tenantId: string;
  createdBy: string;
  createdByName: string;
  createdDate: string;
  avatar: string;
  lastModifiedBy: string;
  lastModifiedByName: string;
  lastModifiedDate: string;
  linkUrl?: string
}
